#pragma once

#include <string>
#include <iostream>

class TextBlock
{
public:
    TextBlock(const std::string &text)
        : text_(text)
    {
    }

    const char& operator[](std::size_t position) const
    {
        std::cout << "TextBlock::operator[] const" << std::endl;
        return text_[position];
    }

    char& operator[](std::size_t position)
    {
        std::cout << "TextBlock::operator[]" << std::endl;
        return const_cast<char&>(static_cast<const TextBlock&>(*this)[position]); // static_cast - show that we want call const method
    }

    void print() const
    {
        std::cout << text_ << std::endl;
    }

private:
    std::string text_;
};

extern TextBlock GlobalTextBlockObject;
